package com.twu.biblioteca.command;

import com.twu.biblioteca.LibraryController;
import com.twu.biblioteca.model.Movie;

public class ListMoviesCommand implements Command{

    private LibraryController libraryController;

    public ListMoviesCommand(LibraryController libraryController) {
        this.libraryController = libraryController;
    }

    @Override
    public void execute() {
        StringBuilder sb = new StringBuilder();
        sb.append("All movies: \n");
        for (Movie movie : libraryController.getMovies()){
            if (movie.isAvailable()){
                sb.append("  ID: ").append(movie.getId()).append(" Name: ").append(movie.getName());
                sb.append("  Director: ").append(movie.getDirector()).append(" Year Published: ").append(movie.getYear());
                sb.append("  Rating: ").append(movie.getRating()).append("\n");
            }
        }
        System.out.println(sb.toString());

    }
}
